/*
 * Copyright 2008 Federal Emergency Management Agency
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 *    
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 *  
 */
package gov.fema.hazus.bdc.server.dto;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DTO_Address extends DTO_AbstractPersistentEntity {
	
    private static final long serialVersionUID = -2311331360421023592L;
    
    public static final String CITY = "city";
    public static final String COUNTRY = "country";
    public static final String COUNTY = "county";
    public static final String POSTALCODE = "postal code";
    public static final String STATE = "state";
    public static final String STREET1 = "street 1";
    public static final String STREET2 = "street 2";
    
    @Persistent private String city;
    @Persistent private String country;
    @Persistent private String county;
    @Persistent private String postalCode;
    @Persistent private String state;
    @Persistent private String street1;
    @Persistent private String street2;
    
    public DTO_Address()
    {
        
    }

    public String getCity() {
        return this.city;
    }

    public String getCountry() {
        return this.country;
    }

    public String getCounty() {
        return this.county;
    }

    public String getPostalCode() {
        return this.postalCode;
    }

    public String getState() {
        return this.state;
    }

    public String getStreet1() {
        return this.street1;
    }

    public String getStreet2() {
        return this.street2;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public void setState(String state) {
        this.state = state;
    }


    public void setStreet1(String street1) {
        this.street1 = street1;
    }

    public void setStreet2(String street2) {
        this.street2 = street2;
    }

    public String asHTML()
    {
        String str = "";
        
        if( street1 != null )
        {
            str += street1;
        }
        
        if( street2 != null )
        {
            str += "<br>" + street2;
        }
        
        if( city != null )
        {
            str += "<br>" + city;
        }
        
        
        if( state != null )
        {
            str += ", " + state;
        }
        
        if( country != null )
        {
            str += "<br>" + country;
        }
        
        if( postalCode != null )
        {
            str += "," + postalCode;
        }

        return str;        
    }
    
    @Override
    public String toString()
    {
        String str = "";
        str += "[address";
        str += "[street1="+this.street1+"]";
        str += "[street2="+this.street2+"]";
        str += "[city="+this.city+"]";
        str += "[county="+this.county+"]";
        str += "[state="+this.state+"]";
        str += "[country="+this.country+"]";
        str += "[postalCode="+this.postalCode+"]";
        str += "]";
        return str;
    }

    

}
